gsk: Fix hexbox drawing for the Vulkan renderer
authorMatthias Clasen <mclasen@redhat.com>
Sat, 6 Jan 2018 01:30:14 +0000 (20:30 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 6 Jan 2018 01:30:14 +0000 (20:30 -0500)
Just as in the cairo renderer, we can get this back
by using pango_cairo_show_glyph_string for populating
the cache.

gsk/gskvulkancolortextpipeline.c
gsk/gskvulkanglyphcache.c
gsk/gskvulkanrenderpass.c
gsk/gskvulkantextpipeline.c

index dd236da880bb1393e3a653054772704674334f8c..9770b279383407f2e5d6491470318dc7b0d0161b 100644 (file)
@@ -122,26 +122,22 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
         {
           double cx = (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
           double cy = (double)(gi->geometry.y_offset) / PANGO_SCALE;
+          GskVulkanColorTextInstance *instance = &instances[count];
+          GskVulkanCachedGlyph *glyph;
 
-          if (!(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
-            {
-              GskVulkanColorTextInstance *instance = &instances[count];
-              GskVulkanCachedGlyph *glyph;
+          glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
 
-              glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
+          instance->tex_rect[0] = glyph->tx;
+          instance->tex_rect[1] = glyph->ty;
+          instance->tex_rect[2] = glyph->tw;
+          instance->tex_rect[3] = glyph->th;
 
-              instance->tex_rect[0] = glyph->tx;
-              instance->tex_rect[1] = glyph->ty;
-              instance->tex_rect[2] = glyph->tw;
-              instance->tex_rect[3] = glyph->th;
+          instance->rect[0] = x + cx + glyph->draw_x;
+          instance->rect[1] = y + cy + glyph->draw_y;
+          instance->rect[2] = glyph->draw_width;
+          instance->rect[3] = glyph->draw_height;
 
-              instance->rect[0] = x + cx + glyph->draw_x;
-              instance->rect[1] = y + cy + glyph->draw_y;
-              instance->rect[2] = glyph->draw_width;
-              instance->rect[3] = glyph->draw_height;
-
-              count++;
-           }
+          count++;
        }
      x_position += gi->geometry.width;
    }
index a17717f7d990b08850c5df440caa0f25b0967238..8d12f5ce66e37a8748771bd4f8fb272cb18baeb7 100644 (file)
@@ -251,8 +251,8 @@ render_glyph (Atlas          *atlas,
   GskVulkanCachedGlyph *value = glyph->value;
   cairo_surface_t *surface;
   cairo_t *cr;
-  cairo_scaled_font_t *scaled_font;
-  cairo_glyph_t cg;
+  PangoGlyphString glyphs;
+  PangoGlyphInfo gi;
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                         value->draw_width * key->scale / 1024,
@@ -260,19 +260,20 @@ render_glyph (Atlas          *atlas,
   cairo_surface_set_device_scale (surface, key->scale / 1024.0, key->scale / 1024.0);
 
   cr = cairo_create (surface);
-
-  scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
-  if (G_UNLIKELY (!scaled_font || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS))
-    return;
-
-  cairo_set_scaled_font (cr, scaled_font);
   cairo_set_source_rgba (cr, 1, 1, 1, 1);
 
-  cg.index = key->glyph;
-  cg.x = - value->draw_x;
-  cg.y = - value->draw_y;
+  gi.glyph = key->glyph;
+  gi.geometry.width = value->draw_width * 1024;
+  if (key->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+    gi.geometry.x_offset = 0;
+  else
+    gi.geometry.x_offset = - value->draw_x * 1024;
+  gi.geometry.y_offset = - value->draw_y * 1024;
+
+  glyphs.num_glyphs = 1;
+  glyphs.glyphs = &gi;
 
-  cairo_show_glyphs (cr, &cg, 1);
+  pango_cairo_show_glyph_string (cr, key->font, &glyphs);
 
   cairo_destroy (cr);
 
index d902a90961fc0ac6147376662f7503a523ff8bcb..83fff2d5e753a4d2e9066af51958e4beb669a3fe 100644 (file)
@@ -413,24 +413,21 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass           *self,
           {
             const PangoGlyphInfo *gi = &glyphs[i];
 
-            if (gi->glyph != PANGO_GLYPH_EMPTY && !(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
+            texture_index = gsk_vulkan_renderer_cache_glyph (renderer, (PangoFont *)font, gi->glyph, op.text.scale);
+            if (op.text.texture_index == G_MAXUINT)
+              op.text.texture_index = texture_index;
+            if (texture_index != op.text.texture_index)
               {
-                texture_index = gsk_vulkan_renderer_cache_glyph (renderer, (PangoFont *)font, gi->glyph, op.text.scale);
-                if (op.text.texture_index == G_MAXUINT)
-                  op.text.texture_index = texture_index;
-                if (texture_index != op.text.texture_index)
-                  {
-                     op.text.num_glyphs = count;
-
-                     g_array_append_val (self->render_ops, op);
-
-                     count = 1;
-                     op.text.start_glyph = i;
-                     op.text.texture_index = texture_index;
-                  }
-                else
-                  count++;
+                op.text.num_glyphs = count;
+
+                g_array_append_val (self->render_ops, op);
+
+                count = 1;
+                op.text.start_glyph = i;
+                op.text.texture_index = texture_index;
               }
+            else
+              count++;
           }
 
         if (op.text.texture_index != G_MAXUINT && count != 0)
index 5ca2d7e00c34123676d63aa7aff5081f1e9af40d..361c53675dab17c4160d161340354f6aeda85f43 100644 (file)
@@ -130,31 +130,27 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
         {
           double cx = (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
           double cy = (double)(gi->geometry.y_offset) / PANGO_SCALE;
+          GskVulkanTextInstance *instance = &instances[count];
+          GskVulkanCachedGlyph *glyph;
 
-          if (!(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
-            {
-              GskVulkanTextInstance *instance = &instances[count];
-              GskVulkanCachedGlyph *glyph;
+          glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
 
-              glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
+          instance->tex_rect[0] = glyph->tx;
+          instance->tex_rect[1] = glyph->ty;
+          instance->tex_rect[2] = glyph->tw;
+          instance->tex_rect[3] = glyph->th;
 
-              instance->tex_rect[0] = glyph->tx;
-              instance->tex_rect[1] = glyph->ty;
-              instance->tex_rect[2] = glyph->tw;
-              instance->tex_rect[3] = glyph->th;
+          instance->rect[0] = x + cx + glyph->draw_x;
+          instance->rect[1] = y + cy + glyph->draw_y;
+          instance->rect[2] = glyph->draw_width;
+          instance->rect[3] = glyph->draw_height;
 
-              instance->rect[0] = x + cx + glyph->draw_x;
-              instance->rect[1] = y + cy + glyph->draw_y;
-              instance->rect[2] = glyph->draw_width;
-              instance->rect[3] = glyph->draw_height;
+          instance->color[0] = color->red;
+          instance->color[1] = color->green;
+          instance->color[2] = color->blue;
+          instance->color[3] = color->alpha;
 
-              instance->color[0] = color->red;
-              instance->color[1] = color->green;
-              instance->color[2] = color->blue;
-              instance->color[3] = color->alpha;
-
-              count++;
-            }
+          count++;
         }
       x_position += gi->geometry.width;
     }